$(function() {
	$(".gotoGoodsDetail").click(function() {
		// var goodsItem = {};
		let data = JSON.parse(localStorage.getItem('$appData'))
		// goodsItem.name = $(this).children("div").eq(1).children("div").children("p").text();
		// goodsItem.price = $(this).children("div").eq(2).children("p").eq(0).children("label").text();
		// goodsItem.repertory = $(this).children("div").eq(2).children("p").eq(1).children("label").text();
		// goodsItem.imgSrc = "../" + $(this).children("div").eq(0).children("img").attr("src");
		// console.log(this.dataset.id)
		let goodsItem = AppData.getGood(data.data, this.dataset.id)
		console.log(goodsItem)
		localStorage.setItem("$detail", JSON.stringify(goodsItem));
		window.location.href = "new-personal-details.html";

	});

	$(".gotoDetail1").click(function() {

		var goodsItem = [{
			"id":"1",
			"title": "影像图书",
			"name": "BEC中级真题和写作",
			"price": 45,
			"repertory": 1,
			"imgSrc": "../images/shop3.jpeg"
			
		}, {
			"id":"5",
			"title": "影像图书",
			"name": "固定收益证券",
			"price": 20,
			"repertory": 1,
			"imgSrc": "../images/shop12.jpeg"
		}];

		localStorage.setItem('$goodsItem', JSON.stringify(goodsItem));

		window.location.href = "new-commodity.html";

	});
	$(".gotoDetail2").click(function() {
		var goodsItem = [{
			"id":'2',
			"title": "家居用品",
			"name": "美的全自动洗衣机",
			"price": 169,
			"repertory": 1,
			"imgSrc": "../images/shop2.jpeg"
		}, {
			"id":'4',
			"title": "家居用品",
			"name": "小熊牌多功能紫砂壶",
			"price": 67,
			"repertory": 1,
			"imgSrc": "../images/shop5.jpeg"
		}];

		localStorage.setItem('$goodsItem', JSON.stringify(goodsItem));

		window.location.href = "new-commodity.html";

	});
	$(".gotoDetail3").click(function() {
		var goodsItem = [{
			"id":'6',
			"title": "数码世界",
			"name": "闲置台灯",
			"price": 18,
			"repertory": 1,
			"imgSrc": "../images/shop7.jpeg"
		}, {
			"id":'7',
			"title": "数码世界",
			"name": "收音机",
			"price": 23,
			"repertory": 1,
			"imgSrc": "../images/shop6.jpeg"
		}];

		localStorage.setItem('$goodsItem', JSON.stringify(goodsItem));

		window.location.href = "new-commodity.html";

	});
	

	$(".gotoDetail4").click(function() {
		var goodsItem = [{
			"id":'8',
			"title": "闲置礼品",
			"name": "蒸脸机",
			"price": 40,
			"repertory": 1,
			"imgSrc": "../images/shop10.jpeg"
		}];

		localStorage.setItem('$goodsItem', JSON.stringify(goodsItem));

		window.location.href = "new-commodity.html";

	});
	
	
	$(".gotoDetail5").click(function() {
		var goodsItem = [{
			"id":'10',
			"title": "服装包饰",
			"name": "女士运动鞋",
			"price": 130,
			"repertory": 1,
			"imgSrc": "../images/shop21.jpeg"
		}];

		localStorage.setItem('$goodsItem', JSON.stringify(goodsItem));

		window.location.href = "new-commodity.html";

	});
	
	
	$(".gotoDetail6").click(function() {
		var goodsItem = [{
			"id":"9",
			"title": "文体用品",
			"name": "花剑",
			"price": 67,
			"repertory": 1,
			"imgSrc": "../images/shop22.jpeg"
		}];

		localStorage.setItem('$goodsItem', JSON.stringify(goodsItem));

		window.location.href = "new-commodity.html";

	});
	
	$(".gotoDetail7").click(function() {
		var goodsItem = [{
			"id":"3",
			"title": "其他",
			"name": "韩后水光裸妆素颜霜",
			"price": 155,
			"repertory": 1,
			"imgSrc": "../images/shop4.jpeg"
		}];

		localStorage.setItem('$goodsItem', JSON.stringify(goodsItem));

		window.location.href = "new-commodity.html";

	});
	
	
	
	//判断有没有登陆，没有则跳转到登陆页
	$("#gotoShoppingCar").click(function(){
		if(localStorage.getItem("$loginUser") == null){
			window.location.href = "login.html"
		}else{
			window.location.href = "new-shopping-card.html"
		}
	});
	
});